/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package digitaldreamers.games.ddmonsters.servers.gameserver.network.packets.sending;

import digitaldreamers.libraries.games.servers.networkmanagement.packets.sending.AbSendablePacket;
import digitaldreamers.games.ddmonsters.servers.gameserver.components.PlayerCardComponent;
import digitaldreamers.games.ddmonsters.servers.gameserver.components.basicinfomation.MonsterCardInformation;
import digitaldreamers.games.ddmonsters.servers.gameserver.configurations.Configuration;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;

/**
 *
 * @author DaoLe
 */
public class SCardsDrawnPacket extends AbSendablePacket {
    
    private ArrayList<PlayerCardComponent> m_drawnCards;
    
    public SCardsDrawnPacket(ArrayList<PlayerCardComponent> drawnCards) {
        m_drawnCards = drawnCards;
        mPacketId = Configuration.CARDS_DRAWN_PACKET_ID;
    }
    
    @Override
    public void writeData(DataOutputStream DOS) throws IOException {
        int iNumberOfDrawnCards = m_drawnCards.size();
        DOS.writeInt(mPacketId);
        DOS.writeInt(iNumberOfDrawnCards);
        for(PlayerCardComponent card : m_drawnCards) {
            MonsterCardInformation monsterCardInformation = (MonsterCardInformation)card.getCardInformation();
            DOS.writeInt(monsterCardInformation.getCardID());
            DOS.writeUTF(monsterCardInformation.getCardName());
            DOS.writeUTF(monsterCardInformation.getCardDescription());
            DOS.writeInt(monsterCardInformation.getCardPrice());
            DOS.writeInt(monsterCardInformation.getGrade());
            DOS.writeInt(monsterCardInformation.getAttackPoint());
            DOS.writeInt(monsterCardInformation.getDefensePoint());
            DOS.writeInt(monsterCardInformation.getHP());
        }
    }
}
